/**
 * @param {number[]} nums
 * @return {number}
 */
var jump = function (nums) {
  let maxNum = 0;
  let n = nums.length;
  let end = 0;
  let step = 0;
  for (let i = 0; i < n - 1; i++) {
    if (i + nums[i] > maxNum) {
      maxNum = i + nums[i];
    }
    if (end === i) {
      step++;
      end = maxNum;
    }
  }
  return step;
};
